From 439cd9a3a505424ea64d099ecbe1b4c910b79649 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 9 Aug 2001 07:57:56 +0000 Subject: [PATCH] tests/prop-editor.c (properties_from_type): Use g_object_class_list_properties to get the param specs for a given type. (#58609) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ tests/prop-editor.c | 39 ++++++++++++++++++--------------------- 8 files changed, 60 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 2f30f7a5fe..587577f0c2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2001-08-09 Matthias Clasen + + * tests/prop-editor.c (properties_from_type): Use + g_object_class_list_properties to get the param specs + for a given type. (#58609) + 2001-08-09 Matthias Clasen * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to diff --git a/tests/prop-editor.c b/tests/prop-editor.c index 353ac79c1a..50c25134b6 100644 --- a/tests/prop-editor.c +++ b/tests/prop-editor.c @@ -23,21 +23,6 @@ #include "prop-editor.h" -static void -get_param_specs (GType type, - GParamSpec ***specs, - gint *n_specs) -{ - GObjectClass *class = g_type_class_peek (type); - - /* We count on the fact we have an instance, or else we'd have - * to use g_type_class_ref (); - */ - - /* Use private interface for now, fix later */ - *specs = NULL; /* class->property_specs; */ - *n_specs = 0; /* class->n_property_specs; */ -} typedef struct { @@ -446,7 +431,7 @@ object_changed (GObject *object, GParamSpec *pspec, gpointer data) name = g_type_name (G_TYPE_FROM_INSTANCE (obj)); else name = "unknown"; - str = g_strdup_printf ("Objetct: %p (%s)", obj, name); + str = g_strdup_printf ("Object: %p (%s)", obj, name); gtk_label_set_text (label, str); g_free (str); @@ -670,12 +655,14 @@ properties_from_type (GObject *object, GtkWidget *sw; GtkWidget *vbox; GtkWidget *table; + GObjectClass *class; + GParamSpec **specs; + gint n_specs; int i; - gint n_specs = 0; - GParamSpec **specs = NULL; - - get_param_specs (type, &specs, &n_specs); + class = G_OBJECT_CLASS (g_type_class_peek (type)); + specs = g_object_class_list_properties (class, &n_specs); + if (n_specs == 0) return NULL; @@ -701,6 +688,13 @@ properties_from_type (GObject *object, continue; } + if (spec->owner_type != type) + { + /* we're only interested in params of type */ + ++i; + continue; + } + label = gtk_label_new (spec->nick); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, i, i + 1); @@ -732,6 +726,9 @@ properties_from_type (GObject *object, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), vbox); + + g_free (specs); + return sw; } @@ -771,7 +768,7 @@ create_prop_editor (GObject *object, GType type) gtk_container_add (GTK_CONTAINER (win), notebook); type = G_TYPE_FROM_INSTANCE (object); - + title = g_strdup_printf ("Properties of %s widget", g_type_name (type)); gtk_window_set_title (GTK_WINDOW (win), title); g_free (title); -- 2.30.2